const Koa = require('koa')
const app = new Koa()
const json = require('koa-json')//用于将http相应的数据解析为json格式
const bodyParder = require('koa-bodyparser')//解析http请求的消息体
const Router = require('@koa/router');
const router = new Router();
const cors=require('@koa/cors')//允许跨域
const mongoose =require('mongoose')
const request = require('koa/lib/request')
const {BASE_URL} =require('./config/Account')

app.use(cors())
app.use(json())
app.use(bodyParder())

//连接数据库
mongoose.connect(BASE_URL).then(res=>{
    console.log('数据库连接成功');
}).catch(err=>{
    console.log('数据库连接失败!!!');
})
//-----接口-------
const login =require('./routes/user/index')
router.use('/apif', login)



router.get('/login',ctx =>{
    console.log('zhe shi yige daunkou')
})
app.use(router.routes()).use(router.allowedMethods())
app.listen(8900)
console.log('端口启动成功')